Node.js Web Development - Fifth Edition by David Herron

Node.js Web Development - Fifth Edition by David Herron

Author:David Herron [David Herron]
Language: eng
Format: epub
Tags: COM060180 - COMPUTERS / Web / Web Services and APIs, COM060160 - COMPUTERS / Web / Web Programming, COM048000 - COMPUTERS / Systems Architecture / Distributed Systems and Computing
Publisher: Packt Publishing
Published: 2020-07-31T04:43:23+00:00


<form method='POST' action='/users/login'>

<div class="form-group">

<label for="username">User name:</label>

<input class="form-control" type='text' id='username'

name='username' value='' placeholder='User Name'/>

</div>

<div class="form-group">

<label for="password">Password:</label>

<input class="form-control" type='password' id='password'

name='password' value='' placeholder='Password'/>

</div>

<button type="submit" class="btn btn-default">Submit</button>

</form>

</div>

</div>

</div>

This is a simple form decorated with Bootstrap goodness to ask for the username and password. When submitted, it creates a POST request to /users/login, which invokes the desired handler to verify the login request. The handler for that URL will start the Passport process to decide whether the user is authenticated.

In views/notedestroy.hbs, we want to display a message if the user is not logged in. Normally, the form to cause the note to be deleted is displayed, but if the user is not logged in, we want to explain the situation, as illustrated in the following code block:

<form method='POST' action='/notes/destroy/confirm'>

<div class="container-fluid">

{{#if user}}

<input type='hidden' name='notekey' value='{{#if

note}}{{notekey}}{{/if}}'>

<p class="form-text">Delete {{note.title}}?</p>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.